package com.cy.detectsys.mapper;

import com.cy.detectsys.entity.DataCenterInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cy.detectsys.entity.vo.DataCenterInfoVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
* @author asus
* @description 针对表【data_center_info】的数据库操作Mapper
* @createDate 2024-06-12 15:48:39
* @Entity com.cy.detectsys.entity.DataCenterInfo
*/
public interface DataCenterInfoMapper extends BaseMapper<DataCenterInfo> {
    List<DataCenterInfo> getDataCenterList(@Param("dataCenterInfoVo") DataCenterInfoVo dataCenterInfoVo);

    @Select("SELECT \n" +
            "    country,\n" +
            "    SUM(asset_count) AS asset_count\n" +
            "FROM \n" +
            "    data_center_info\n" +
            "GROUP BY \n" +
            "    country\n" +
            "ORDER BY \n" +
            "    asset_count DESC;")
    List<Map> countAsset();

    @Select("SELECT asset_count,available_areas FROM `data_center_info` ORDER BY asset_count desc limit 5")
    List<Map> getAssetlink();

    @Select("SELECT\n" +
            "\tcountry,\n" +
            "\tCOUNT( country ) countryNum \n" +
            "FROM\n" +
            "\tdata_center_info \n" +
            "GROUP BY\n" +
            "\tcountry \n" +
            "ORDER BY\n" +
            "\tcountryNum DESC \n" +
            "\tLIMIT 0,5")
    List<Map> getCountryDataCenterSort();

    @Select("SELECT\n" +
            "\tavailable_areas,\n" +
            "\tasset_count\n" +
            "FROM\n" +
            "\tdata_center_info \n" +
            "ORDER BY\n" +
            "\tasset_count DESC \n" +
            "\tLIMIT 0,5")
    List<Map> getDataCenterAssetSort();

    @Select("SELECT COUNT(cloud_service) FROM `ip_net_cloud_service_info`")
    Integer getCloudServiceCount();

    @Select("SELECT\n" +
            "\tCOUNT( DISTINCT ip ) \n" +
            "FROM\n" +
            "\t`probe_result_connect_cloud` \n" +
            "WHERE\n" +
            "\tdata_center_name = #{dataCenterName}")
    Integer selectIpv4count(String dataCenterName);


}





